package com.wlan.dao.manage;

import com.wlan.dao.common.AbstractTestCase;
import com.wlanauth.core.criteria.GeneralCriteria;
import com.wlanauth.core.criteria.GeneralCriteriaQuery;
import com.wlanauth.core.criteria.GeneralCriteriaResult;
import com.wlanauth.dao.manage.OperatorDao;
import com.wlanauth.dao.manage.RoleDao;
import com.wlanauth.domain.manage.Operator;
/**
 * 操作员
 * @author zz
 * @date 2012-5-10
 * @email charles.zz.life@gmail.com
 */
public class OperaotrTestCase extends AbstractTestCase {
	
	
	
	public void testSave(){
		RoleDao roleDao = (RoleDao)this.getCtx().getBean("manage.RoleDao");
		OperatorDao operDao = (OperatorDao)this.getCtx().getBean("manage.OperatorDao");
		operDao.getByUsername("zz");
//		Role role = roleDao.load("1");
//		
//		//
//		Operator t = new Operator();
//		t.setUsername("zz");
//		t.setPassword("zz");
//		t.setBirth(new Date());
//		t.setDisplayname("zzz");
//		t.setSexId("F");
//		t.setRole(role);
//		
//		OperatorDao operDao = (OperatorDao)this.getCtx().getBean("manage.OperatorDao");
//		
//		operDao.save(t);
	}
	
	/**
	 * 测试查询
	 */
	public void testQuery(){
		GeneralCriteria criteria = new GeneralCriteria(Operator.class);
		GeneralCriteriaQuery query = new GeneralCriteriaQuery();
		
		GeneralCriteriaResult<Operator> result = query.execute(criteria);
		for(Operator p:result.getData()){
			System.out.println("username:"+p.getUsername()+",roleId:"+p.getRole().getName());
		}
	}
}
